/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.firstpart.guize.mapper.GuiZeMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.firstpart.guize.mapper;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.processor.*;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.location.entity.OrderNoticeEntity;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class GuiZeMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;

    public OrderNoticeEntity selectOrdernoticeEntity(String orderid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxq_ordernotice where `orderid`=? and type=? and ytenant_id=? and dr=0 limit 1;\n";
        parameter.addParam(orderid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrderNoticeEntity());
        return (OrderNoticeEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int UpdateordernoticeList(String actioncode, Integer auditstatus, String orderid, String ordertype, String tenant_id, String modifier, int repickstatus) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "UPDATE `dxq_ordernotice` SET `actioncode`=?,`auditstatus`=?,modifier=?,`repickstatus` = ?,tenant_id=?,ytenant_id=? where `orderid`=? and type=? and dr=0\n";
        parameter.addParam(actioncode);
		parameter.addParam(auditstatus);
		parameter.addParam(modifier);
		parameter.addParam(repickstatus);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(orderid);
		parameter.addParam(ordertype);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int Updateordernotice(String actioncode, String transtype, Integer auditstatus, String id, String tenant_id, String modifier) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "UPDATE `dxq_ordernotice` SET `actioncode`=?,`transtype`=?,`auditstatus`=?,modifier=?,tenant_id=?,ytenant_id=? where `id`=? and dr=0\n";
        parameter.addParam(actioncode);
		parameter.addParam(transtype);
		parameter.addParam(auditstatus);
		parameter.addParam(modifier);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(id);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int Insertordernotice(Integer type, String actioncode, String transtype, String orderid, String ordercode, String orderdetailids, String sourceid, String sourcecode, String sourcedetailids, String firstsourceid, String firstsourcecode, String firstsourcedetailids, String tenant_id, String creator, Integer auditstatus, Integer repickstatus) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "INSERT INTO `dxq_ordernotice`(`type`,`actioncode`,`transtype`,`orderid`,`ordercode`,`orderdetailids`,`sourceid`,`sourcecode`,`sourcedetailids`,`firstsourceid`,`firstsourcecode`,`firstsourcedetailids`,`status`,`dr`,`tenant_id`,`ytenant_id`,`creator`,`auditstatus`,`repickstatus`)\n" + 
			         "values(?,?,?,?,?,?,?,?,?,?,?,?,0, 0,?,?,?,?,?)                                                                                                                                                                                                                                        \n";
        parameter.addParam(type);
		parameter.addParam(actioncode);
		parameter.addParam(transtype);
		parameter.addParam(orderid);
		parameter.addParam(ordercode);
		parameter.addParam(orderdetailids);
		parameter.addParam(sourceid);
		parameter.addParam(sourcecode);
		parameter.addParam(sourcedetailids);
		parameter.addParam(firstsourceid);
		parameter.addParam(firstsourcecode);
		parameter.addParam(firstsourcedetailids);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(creator);
		parameter.addParam(auditstatus);
		parameter.addParam(repickstatus);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public OrderNoticeEntity selectOrderNoticeById(String orderId) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "Select * from `dxq_ordernotice` where dr = 0 and orderid = ? limit 1\n";
        parameter.addParam(orderId);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrderNoticeEntity());
        return (OrderNoticeEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public List<OrderNoticeEntity> selectOrdernoticeAll(String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxq_ordernotice where ytenant_id=? and dr=0;\n";
        parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new OrderNoticeEntity());
        return (List<OrderNoticeEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int InsertordernoticeList(Integer type, String actioncode, String transtype, String orderid, String ordercode, String orderdetailids, String sourceid, String sourcecode, String sourcedetailids, String firstsourceid, String firstsourcecode, String firstsourcedetailids, String tenant_id, String creator, Integer auditstatus, Integer repickstatus) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "INSERT INTO `dxq_ordernotice`(`type`,`actioncode`,`transtype`,`orderid`,`ordercode`,`orderdetailids`,`sourceid`,`sourcecode`,`sourcedetailids`,`firstsourceid`,`firstsourcecode`,`firstsourcedetailids`,`status`,`dr`,`tenant_id`,`ytenant_id`,`creator`,`auditstatus`,`repickstatus`)\n" + 
			         "values(?,?,?,?,?,?,?,?,?,?,?,?,0, 0,?,?,?,?,?)                                                                                                                                                                                                                                        \n";
        parameter.addParam(type);
		parameter.addParam(actioncode);
		parameter.addParam(transtype);
		parameter.addParam(orderid);
		parameter.addParam(ordercode);
		parameter.addParam(orderdetailids);
		parameter.addParam(sourceid);
		parameter.addParam(sourcecode);
		parameter.addParam(sourcedetailids);
		parameter.addParam(firstsourceid);
		parameter.addParam(firstsourcecode);
		parameter.addParam(firstsourcedetailids);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(creator);
		parameter.addParam(auditstatus);
		parameter.addParam(repickstatus);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public OrderNoticeEntity selectOrderNoticeByIdAndType(String orderId, String orderType) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "Select * from `dxq_ordernotice` where dr = 0 and orderid = ? and type = ?  limit 1\n";
        parameter.addParam(orderId);
		parameter.addParam(orderType);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrderNoticeEntity());
        return (OrderNoticeEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

}
